package com.spzx.product.api.factory;

import com.spzx.common.core.domain.R;
import com.spzx.product.api.RemoteBrandService;
import com.spzx.product.api.domain.Brand;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * ClassName: RemoteBrandFallbackFactory
 * Package: com.spzx.product.api.factory
 * Description:
 *
 * @Author 咚咚小圆帽
 * @Create 2025/3/16 21:03
 * @Version 1.0
 */
@Component
@Slf4j
public class RemoteBrandFallbackFactory implements FallbackFactory<RemoteBrandService> {

    @Override
    public RemoteBrandService create(Throwable throwable) {
        log.error("商品服务调用失败:{}", throwable.getMessage());

        return new RemoteBrandService() {
            @Override
            public R<List<Brand>> getBrandAllList(String source) {
                return R.fail("获取全部品牌失败:" + throwable.getMessage());
            }
        };
    }
}
